//
//  EMPopView.m
//  ElectronicMall
//
//  Created by 史伟文 on 15/2/3.
//  Copyright (c) 2015年 cczu. All rights reserved.
//

#import "EMPopView.h"

@implementation EMPopView
{
    CGRect rect;
    UIView *popBackView;
    NSArray *titleArray;
}
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    
    if (self) {
        
        titleArray = [NSArray array];
        rect = frame;
    }
    
    return self;
}

- (id)initWithTableView:(NSArray *)contentList
{
    if (self = [super init])
    {
        titleArray = contentList;
        UITableView *popTableView = [[UITableView alloc] initWithFrame:CGRectMake(10, [UIScreen mainScreen].bounds.size.height / 2 - 150, 300, 300)];
        popTableView.delegate = self;
        popTableView.dataSource = self;
        popTableView.backgroundColor = [UIColor cyanColor];
        [popBackView addSubview:popTableView];
    }
    return self;
}
- (void)createPopItemWithNum: (int)num
{
    
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return titleArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *cellIdentifier = @"cl0";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:0 reuseIdentifier:cellIdentifier];
    }
    cell.textLabel.text = titleArray[indexPath.row];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 60;
}


- (void)show
{
    // 设置提醒的位置和大小
    popBackView = [[UIView alloc] init];
    popBackView.frame = [UIScreen mainScreen].bounds;
    [self addSubview:popBackView];
}

- (void)dismissAlert
{
    // 将提醒移出
    [popBackView removeFromSuperview];
    if (self.dismissBlock)
    {
        self.dismissBlock();
    }
}


@end
